import java.util.Iterator;
import java.util.TreeSet;

public class Demo {
    public static void main(String[] args) {
        TreeSet<Student> ts = new TreeSet<Student>(new Comp());
        ts.add(new Student("abc03"));
        ts.add(new Student("abc02"));
        ts.add(new Student("abc06"));
        ts.add(new Student("abc01"));

        Iterator<Student> it = ts.iterator();
        while (it.hasNext()) {
            System.out.println(it.next().getName());
        }


        TreeSet<Worker> ts1 = new TreeSet<Worker>(new Comp());
        ts1.add(new Worker("wabc--03"));
        ts1.add(new Worker("wabc--02"));
        ts1.add(new Worker("wabc--06"));
        ts1.add(new Worker("wabc--01"));

        Iterator<Worker> it1 = ts1.iterator();
        while (it1.hasNext()) {
            System.out.println(it1.next().getName());
        }
    }
}
